package com.ls.pattern.structure.flyweight;

import java.util.HashMap;

//网站工厂
public class WebsiteFactory {

    private HashMap<String, ConcreteWebSite> pool = new HashMap<>();

    //根据网站类型,返回一个网站,如果没有就创建一个网站,并放入池中
    public WebSite getWebSite(String type) {
        if (!pool.containsKey(type)) {
            pool.put(type, new ConcreteWebSite(type));
        }

        return pool.get(type);
    }

    public int getCount(){
        return pool.size();
    }

}
